<?php
/**
 * User: zhengze
 * Date: 2020/4/21
 * Time: 15:48
 */

namespace app\tool\controller;

use common\controller\BaseController;
use Qiniu\Auth;
use think\response\Json;

class Img extends BaseController
{

    /**
     * 初始化函数
     * @return boolean
     */
    protected function initialize()
    {
        parent::initialize();
        return true;
    }

    /**
     * 获取七牛token
     * @return Json
     */
    public function getToken()
    {
        $accessKey = 'ePmKtzi8EmCOCGswcF0gYHt4NBYp7cAWWXR-2mfK';
        $secretKey = 'J6XK0LxuNWeXjLw2e7pTZjDUdxLOTxAiX5N44QHn';
        $bucket = 'challengex';
        // 生成上传Token
        $auth = new Auth($accessKey, $secretKey);
        $token = $auth->uploadToken($bucket);
        return $this->json_responce(['token' => $token]);
    }

}